package com.pactera.madp.cp.controller.oms.job;

import com.pactera.madp.common.log.annotation.SysLog;
import com.pactera.madp.common.security.annotation.Inner;
import com.pactera.madp.cp.service.IWorkMsgService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Inner
@RestController
@RequestMapping("/job-task")
@Api(value = "job-task", tags = "会话同步任务")
public class WorkMsgAsyncTaskController {

    private static final String OS_LINUX = "linux";
    @Autowired
    private IWorkMsgService workMsgService;

    @SysLog("会话同步任务")
    @PostMapping("/async-msg")
    public void onAsyncMsg() {
        String osName = System.getProperty("os.name").toLowerCase();
        if (OS_LINUX.equals(osName)) {
            workMsgService.onAsyncMsg();
        }
    }

    @SysLog("会话删除任务")
    @DeleteMapping("/clear-msg")
    public void clearExpireMsg() {
        workMsgService.clearExpireMsg();
    }

}
